package org.example.cloudalibaba.controller;

import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import org.example.cloudalibaba.entity.Order;
import org.example.cloudalibaba.service.OrderService;
import org.example.springcloud.common.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class OrderController {
    @Resource
    private OrderService orderService;

    @PostMapping("/order/create")
    @GlobalTransactional
    public Result create(Order order) {
        orderService.create(order);
        return Result.success("订单{}创建成功", order.getId());
    }
}
